home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Form1"
- ClientHeight = 5820
- ClientLeft = 1095
- ClientTop = 1770
- ClientWidth = 7365
- Height = 6510
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 5820
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Begin CommandButton Command1
- Caption = "Create Directory"
- Height = 495
- Left = 2505
- TabIndex = 0
- Top = 2685
- Width = 2055
- End
- Begin Menu mnuExit
- Caption = "Exit"
- End
- Sub Command1_Click ()
- 'Specify the directory to create
- DirName$ = "C:\VB\TEST1"
- If Not DirExists(DirName$) Then
- 'Directory does not exist, so create it
- I% = CreateDir(DirName$)
- Select Case I%
- Case True
- Msg$ = DirName$ + " successfully created."
- Case False
- Msg$ = DirName$ + " not created due to error."
- End Select
- Else
- 'Directory exists
- Msg$ = DirName$ + " already exists"
- End If
- MsgBox Msg$
- End Sub
- Function CreateDir (DirName$) As Integer
- 'This function will return TRUE if the directory passed
- 'to it was successfully created; FALSE if an error occurrs
- On Error Resume Next
- MkDir DirName$
- If Err Then
- CreateDir = False
- Else
- CreateDir = True
- End If
- End Function
- Function DirExists (DirName$) As Integer
- 'This function will return TRUE if the directory passed
- 'to it exists; FALSE if it doesn't or a runtime error
- 'occurs
- Const ATTR_DIRECTORY = 16
- Const ATTR_HIDDEN = 2
- On Error Resume Next
- If Len(Dir$(DirName$, ATTR_DIRECTORY + ATTR_HIDDEN)) = 0 Then
- DirExists = False
- Else
- DirExists = True
- End If
- End Function
- Sub Form_Unload (Cancel As Integer)
- End
- End Sub
- Sub mnuExit_Click ()
- Unload Me
- End Sub
-